#include <cstdio>
const int N = 100010;
int n, m, b[N];
inline void add(int i) {
  for (; i <= N; i += i & -i) b[i] ^= 1;
}
inline int query(int i) {
  int res = 0;
  for (; i; i -= i & -i) res ^= b[i];
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int op, l, r;
    scanf("%d%d", &op, &l);
    if (op == 1)
      add(l), scanf("%d", &r), add(r + 1);
    else
      printf("%d\n", query(l));
  }
}
